#! /usr/bin/python
# -*- coding:utf-8 -*-

## ========================================================================
## Copyright (C) 2007-2013  Jean-Philippe GOLAY
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
## ========================================================================

from product import *
import cgi

form = cgi.FieldStorage()
msg=""

print u"Content-type: text/plain"
print

if form.has_key(u"session"): 
  session = form[u"session"].value

if form.has_key(u"id"): 
  product_id = form[u"id"].value
else:
  msg+=u"<br/>***Manque id produit !***"

# GET DETAILS PRODUCT
prod=Product()
p = prod.read(product_id)
if p == 0:
  print "<b>Aucun d&eacute;tails disponible pour ce produit !<b><br/>%s" % msg
else:  
  src_img = 'img/' + p[u'prod_img']
  html = "<table border='0' cellspacing='0' cellpadding='0' align='center' class='detail_product'><tr><td class='text_left'><b>R&eacute;f&eacute;rences</b></td><td class='text_left'><b>D&eacute;signation</b></td><td class='text_right'><b>Prix</b></td><td rowspan='6'><img src='%s' title='%s' alt='%s' height='300' width='300'/></td></tr><tr><td class='text_left'>%s</td><td class='text_left'>%s</td><td class='text_right'><h3>%s&euro;</h3></td></tr><tr><td colspan='3' class='text_left'><b>Description</b></td></tr><tr><td colspan='3' class='text_left'>%s</td></tr><tr><td colspan='3' class='text_left'><b>Option</b></td></tr><tr><td colspan='3' class='text_left' valign='top'>%s</td></tr><tr><td colspan='2' class='text_left'>Produit disponible : %s</td><td colspan='2'><a id='%s' href='#' onclick='addCaddy(this.id)' title='Ajouter au pannier'>Ajouter au panier</a></td></tr></table><input type='hidden' id='designation' value='%s'/><input type='hidden' id='price' value='%s'/><input type='hidden' id='tax' value='%s'/><input type='hidden' id='reference' value='%s'/>" % ( src_img, p[u'prod_desig'], p[u'prod_desig'], p[u'prod_ref'], p[u'prod_desig'], p[u'prod_price'], p[u'prod_desc'], p[u'prod_option'], p[u'prod_dispo'], product_id, p[u'prod_desig'], p[u'prod_price'] , p[u'prod_tax'] , p[u'prod_ref'] )

  print html

